package pl.edu.amu.wmi.kino.visualjavafx.model.objects;

import java.awt.Color;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Showable;
import java.util.ArrayList;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.9E8C0F52-8ABD-991E-87B7-B0DF78E1230E]
// </editor-fold> 
public class Canvas implements ContentContainer, Showable, java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.743C92D3-74CB-EDE1-50F4-C3E9777F8975]
    // </editor-fold> 
    private Color BgColor;
    private boolean visible;

    private ArrayList<VisualObject> content = new ArrayList<VisualObject>();


    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.E9F6AF86-EC6C-A4C3-DC55-5F610D6220CB]
    // </editor-fold> 
    public Canvas () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A6344AAF-65E9-764E-2AF9-FEE287AAD0D7]
    // </editor-fold> 
    @Override
    public ArrayList<VisualObject> getContent () {
        return content;
    }


    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.DCA26466-12BD-2215-29A9-EA3140E56D4F]
    // </editor-fold> 
    @Override
    public void setVisibility (boolean val) {
        boolean oldVal = this.visible;
        this.visible=val;
        propertySupport.firePropertyChange( "visible" , oldVal, val);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.BAD8908E-BD03-8025-2977-79EF38A949CB]
    // </editor-fold> 
    @Override
    public boolean getVisibility () {
        return this.visible;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.B321F269-4326-1672-BF43-7E469D07CF48]
    // </editor-fold> 
    public Color getBgColor () {
        return BgColor;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.C574609E-DA76-71F5-BC7D-4206A15C5965]
    // </editor-fold> 
    public void setBgColor (Color val) {
        Color oldVal = this.BgColor;
        this.BgColor=val;
        propertySupport.firePropertyChange( "BgColor" , oldVal, val);
    }

    public Canvas shallowClone(){
        Canvas res = new Canvas();
        res.visible=this.visible;
        res.BgColor=new Color(this.BgColor.getRGB());
        for(VisualObject o : this.content){
            res.content.add(o.shallowClone());
        }
        return res;
    }

}

